package cn.tedu.coolshark.controller;

import cn.tedu.coolshark.mapper.UserMapper;
import cn.tedu.coolshark.pojo.dto.UserDto;
import cn.tedu.coolshark.pojo.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;

@RestController
public class UserController {
    @Autowired
    UserMapper mapper;

    @RequestMapping("/login")
    public int login(@RequestBody UserDto userDto) {
        UserVo user = mapper.selectByUsername(userDto.getUsername());
        if (user != null) {
            if (user.getPassword().equals(userDto.getPassword())) {
              //判断是否需要记住用户名和密码
                if (userDto.getRem()){
                    new Cookie()
                }
                return 1;
            }
            return 2;
        }
        return 3;
    }
}
